# -*- coding: utf-8 -*-
from django import forms
from hosting.hosts.models import Host

class AddHostForm(forms.Form):
    host = forms.CharField()

    def clean_host(self):
        host = self.cleaned_data['host']
        try:
            Host.objects.get(name=host)
        except Host.DoesNotExist:
            return host
        raise forms.ValidationError("Host "+host+" already exist!")

class UpdateHostForm(forms.ModelForm):
    id = forms.IntegerField(widget = forms.HiddenInput)
    status = forms.ChoiceField(choices=(('1','enable'),('0','disable')))
    class Meta:
        model = Host
        fields = ('id','name','email','status')
